package com.zlx.sharelive.activity;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.zlx.module_base.base_ac.BaseAc;
import com.zlx.module_base.base_api.res_data.InviteUserBean;
import com.zlx.module_base.base_api.util.ApiUtil;
import com.zlx.module_base.base_util.SPUtil;
import com.zlx.module_network.api1.livedata.BaseObserver;
import com.zlx.module_network.api1.livedata.BaseObserverCallBack;
import com.zlx.module_network.bean.ApiResponse;
import com.zlx.sharelive.R;
import com.zlx.sharelive.adapter.CommonRecyclerViewAdapter;
import com.zlx.sharelive.adapter.CommonRecyclerViewHolder;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 推广记录
 */
public class PromotionRecordAc extends BaseAc {


    @BindView(R.id.rv_data)
    RecyclerView rv_data;


    private int page=1;
    private List<InviteUserBean.InfoDTO> mList=new ArrayList<>();
    private CommonRecyclerViewAdapter<InviteUserBean.InfoDTO> mAdapter;

    @Override
    protected int getLayoutId() {
        return R.layout.ac_promotion_record;
    }

    @Override
    public void initViews() {
        super.initViews();

        getInviteUser(page);
        initRecyclerView();
    }

    private void getInviteUser(int page) {
        ApiUtil.getUserApi().getInviteUser(SPUtil.getToken(this),
                String.valueOf(page)).observe(this, new BaseObserver<>(new BaseObserverCallBack<ApiResponse<InviteUserBean>>() {
            @Override
            public void onSuccess(ApiResponse<InviteUserBean> data) {

            }
        }));
    }

    private void initRecyclerView() {
        rv_data.setLayoutManager(new LinearLayoutManager(this));

        mAdapter = new CommonRecyclerViewAdapter<InviteUserBean.InfoDTO>(this, mList) {
            @Override
            public void convert(CommonRecyclerViewHolder holder, InviteUserBean.InfoDTO entity, int position) {

            }

            @Override
            public int getLayoutViewId(int viewType) {
                return R.layout.item_promotion_record;
            }
        };

        rv_data.setAdapter(mAdapter);
    }
}
